import jieba
from gensim import corpora
from gensim import models
from gensim import similarities


def getfeaturs(l1, a):
    all_doc_list = []
    for doc in l1:
        doc_list = [word for word in jieba.cut(doc)]
        all_doc_list.append(doc_list)
    doc_test_list = [word for word in jieba.cut(a)]
    dictionary = corpora.Dictionary(all_doc_list)
    corpus = [dictionary.doc2bow(doc) for doc in all_doc_list]
    doc_test_vec = dictionary.doc2bow(doc_test_list)
    corpus.append(dictionary.keys())
    print(corpus)
    return corpus, doc_test_vec


def printresult(sim, l1, a):
    cc = sorted(enumerate(sim, l1, a))
    text = l1[cc[0][0]]
    print(a, '和:',text)
